package com.soker.video.service;

import com.soker.fan.pojo.FanBarrageCartitem;
import com.soker.user.pojo.User;
import com.soker.video.mapper.VideoMapper;
import com.soker.video.pojo.Video;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class VideoServiceImpl implements VideoService{
    @Autowired
    VideoMapper videoMapper;
    //查找所有Video
    public List<Video> findAllVideo(){return videoMapper.findAllVideo();}
    //查找指定种类的视频
    public List<Video> findAllVideoByClass(int classfication){return videoMapper.findAllVideoByClass(classfication);}
    //查找所有Video
    public List<Video> findAllVideoHu(String vname){return videoMapper.findAllVideoHu(vname);}
    //按Video名查询
    public Video findVideoByVname(String vname){return videoMapper.findVideoByVname(vname);}
    //按Vid查询
    public Video findVideoByVid(String vid){return videoMapper.findVideoByVid(vid);}
    //查询某条视频是否被某用户点赞过
    public String isZanForUser(Map map){return videoMapper.isZanForUser(map);}
    //插入默认点赞记录
    public void insertDefaultZan(Map map){videoMapper.insertDefaultZan(map);}
    //点赞
    public void updateZan(String vid){videoMapper.updateZan(vid);}
    //点赞后变为true
    public void chanIszan(Map map){videoMapper.chanIszan(map);}
    //取消点赞
    public void cancelZan(String vid){videoMapper.cancelZan(vid);}
    //取消点赞后变为false
    public void chanIszan2(Map map){videoMapper.chanIszan2(map);};
    //查询某条视频是否被某用户投币过（投币没有取消)
    public String isBiForUser(Map map){return videoMapper.isBiForUser(map);}
    //投币
    public void updateBi(String vid){videoMapper.updateBi(vid);}
    //投币后变为true
    public void chanIsbi(Map map){videoMapper.chanIsbi(map);}
    //查询某条视频是否被某用户收藏过
    public String isCangForUser(Map map){return videoMapper.isCangForUser(map);}
    //收藏
    public void updateCang(String vid){videoMapper.updateCang(vid);}
    //收藏后变为true
    public void chanIscang(Map map){videoMapper.chanIscang(map);}
    //取消收藏
    public void cancelCang(String vid){videoMapper.cancelCang(vid);}
    //取消收藏后变为false
    public void chanIscang2(Map map){videoMapper.chanIscang2(map);}
    //查找对应video的所有评论，显示其信息
    public List<FanBarrageCartitem> findBarrageByVname(Map map){return videoMapper.findBarrageByVname(map);}
    //vid查找vname
    public String findVnameByVid(String vid){return videoMapper.findVnameByVid(vid);}
    //插入评论
    public void insertBarrage(Map map){videoMapper.insertBarrage(map);}
    //creator查找up信息
    public User findUpByCreator(int creator){return videoMapper.findUpByCreator(creator);}
    //查询当前登录用户是否关注了当前video的up
    public boolean isFans(Map map){return videoMapper.isFans(map)==1;}
    //关注up
    public void focusUp(Map map){videoMapper.focusUp(map);}
    //取消关注
    public void cancelFocus(Map map){videoMapper.cancelFocus(map);}
    //关注数+1
    public void updateUp(String upid){videoMapper.updateUp(upid);}
    //关注数-1
    public void cancelUp(String upid){videoMapper.cancelUp(upid);}
    //关注数+1
    public void updateUp2(String fansid){videoMapper.updateUp2(fansid);}
    //关注数-1
    public void cancelUp2(String fansid){videoMapper.cancelUp2(fansid);}
    //插入历史记录
    public void insertHis(Map map){videoMapper.insertHis(map);}
    //查询当前用户是否有当前记录
    public boolean exsitHis(Map map){return videoMapper.exsitHis(map)==1;}
    //已存在当前记录，更新日期
    public void exsitUpdate(Map map){videoMapper.exsitUpdate(map);}
    //得到nickname
    public String getNickname(int uid){return videoMapper.getNickname(uid);}
    //播放量+1
    public void updateTot(String vid){videoMapper.updateTot(vid);}
    //按风格查询
    public List<Video> findByClassification(String vclassid){return videoMapper.findByClassification(vclassid);}
    //按风格查询2
    public List<Video> findByClassification2(Map map){return videoMapper.findByClassification2(map);}

}
